package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.SchedulingOut;
import com.dragon.repository.entity.SchedulingOutSon;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class SchedulingOutVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "生产单id")
    private String produceId;

    @ApiModelProperty(value = "公司名称")
    private String companyName;

    @ApiModelProperty(value = "供应商id")
    private String supplierId;

    @ApiModelProperty(value = "联系人")
    private String contactName;

    @ApiModelProperty(value = "联系人电话")
    private String phone;

    @ApiModelProperty(value = "生产状态1生产中2生产完成")
    private Integer type;

    @ApiModelProperty(value = "外发总额")
    private Double money;

    @ApiModelProperty(value = "外发数量")
    private Integer schedulingOutNum;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "外发时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date outGoingTime;

    @ApiModelProperty(value = "外发子表")
    private List<SchedulingOutSon> schedulingOutSonList;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static SchedulingOut convert(SchedulingOutVO vo) {
        SchedulingOut entity = new SchedulingOut();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<SchedulingOut> convertList(List<SchedulingOutVO> list) {
        List<SchedulingOut> resultList = new ArrayList<>();
        for (SchedulingOutVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
